package com.baosight.sczx.zm.cm.service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.baosight.iplat4j.core.ei.EiBlockMeta;
import com.baosight.iplat4j.core.ei.EiColumn;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.ef.ui.tree.TreeService;
import com.baosight.sczx.common.zm.cInterface.Department;

public class ServiceZMCM40 extends TreeService {
	
	
	/**
	 * <p>Function: getTopNodes</p>
	 * <p>Description: 材料费用额度管理树根节点</p>
	 * <p>return value:List</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2011-6-21 15:33:10 李红星 create
	 * </p>
	 *
	 */
	@Override
	public List<Map<String, String>> getTopNodes() {
		List<Map<String, String>> nodesList = new ArrayList<Map<String, String>>();
		Map<String, String> topMap = new HashMap<String, String>();
		topMap.put("label", "topUnit");
		topMap.put("text", "生产区队");		
		topMap.put("leaf", "0");
		nodesList.add(topMap);

		return nodesList;
	}
	/**
	 * <p>Function: getChildNodes</p>
	 * <p>Description: 接口调用查询树的孩子节点</p>
	 * <p>return value: ServiceZMCM40</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2011-6-21 15:33:52 李红星
	 * </p>
	 *
	*/
	@SuppressWarnings("rawtypes")
	@Override
	public List getChildNodes(String arg0) {
		List<Map> childNodes = new ArrayList<Map>();
		childNodes = Department.getInstance().getDepartmentForTree();
		return childNodes;
	}

	/**
	 * <p>Function: initMetaData</p>
	 * <p>Description: 构造树的block</p>
	 * <p>return value: ServiceZMCM40</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2011-6-21 15:33:52 李红星
	 * </p>
	 *
	*/
	@Override
	public EiBlockMeta initMetaData() {
		EiBlockMeta eiMetadata = new EiBlockMeta();

		EiColumn eiColumn = new EiColumn("label");
		eiColumn.setDescName("label");
		eiColumn.setNullable(false);
		eiColumn.setPrimaryKey(false);
		eiMetadata.addMeta(eiColumn);

		eiColumn = new EiColumn("text");
		eiColumn.setDescName("text");
		eiColumn.setNullable(false);
		eiColumn.setPrimaryKey(false);
		eiMetadata.addMeta(eiColumn);

		eiColumn = new EiColumn("leaf");
		eiColumn.setDescName("leaf");
		eiColumn.setType(EiConstant.COLUMN_TYPE_NUMBER);
		eiColumn.setNullable(false);
		eiColumn.setPrimaryKey(false);
		eiMetadata.addMeta(eiColumn);
		
		return eiMetadata;
	}

}
